//删除dir文件夹
const fs = require("fs");
const path = require("path");
let dirName = process.argv[2];
let filePath = path.join(__dirname, dirName);
console.log(filePath);
function delDir(filePath) {
    let statObj = fs.statSync(filePath);
    if (statObj.isFile()) {
        fs.unlink(filePath);
    }
    else if (statObj.isDirectory()) {
        let childList = fs.readdirSync(filePath);
        console.log(childList);
        for (let i = 0; i < childList.length; i++) {
            let childPath = path.join(filePath, childList[i]);
            console.log(childPath);
            let childObj = fs.statSync(childPath);
            if (childObj.isFile()) {
                fs.unlinkSync(childPath);
            }
            else if (childObj.isDirectory()) {
                delDir(childPath);
            }
        }
        fs.rmdirSync(filePath);

    }

}
delDir(filePath);
